<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>17-循环大练习</title>
</head>

<body>
  <script>


    //练习 2  计算从 1 到 100 的总和并输出
    //2. 页面输入 1-100 累加和
    // let i = 1
    // let sum = 0
    // while(i <= 100){
    //   sum = sum + i
    //   i++
    // }
    // console.log(sum);

    //练习 3 计算从 1 到 100 的所有偶数和  2550
     let i = 1
     let sum = 0
     while(i <= 100){
      if(i % 2 === 0){
        sum = sum + i
        console.log(i);
        i++
      }
      i++  
    }
    console.log(sum);
  </script>
</body>
</html>